package one.stand.controller;

import one.stand.entity.excel.CustomerExcelEntity;
import one.stand.model.ResultModel;
import one.stand.request.CustomerRequest;
import one.stand.request.InputDealMoneyRequest;
import one.stand.response.CustomerResponse;
import one.stand.response.GetCustomerInfoResponse;
import one.stand.util.ExportDataDTO;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("customer")
public class CustomerController extends BaseController {

    /**
     * 录入成交金额
     *
     * @return
     */
    @PostMapping("inputDealMoney")
    public ResultModel<Boolean> inputDealMoney(@RequestBody InputDealMoneyRequest request) {
        return customerService.inputDealMoney(request);
    }

    /**
     * 删除成交记录表图片
     *
     * @return
     */
    @PostMapping("delInputDealPhotos")
    public ResultModel<Boolean> delInputDealPhotos(@RequestBody InputDealMoneyRequest request) {
        return customerService.delInputDealPhotos(request);
    }

    /**
     * 存为客户
     *
     * @param request
     * @return
     */
    @PostMapping("addCustomer")
    public ResultModel<Boolean> addCustomer(@RequestBody CustomerRequest request) {
        return customerService.addCustomer(request);
    }

    /**
     * 客户类型分组统计
     *
     * @param request
     * @return
     */
    @PostMapping("countCustomer")
    public ResultModel<List<CustomerResponse>> countCustomer(@RequestBody CustomerRequest request) {
        return customerService.countCustomer(request);
    }

    /**
     * 获取客户列表
     *
     * @param request
     * @return
     */
    @PostMapping("getCustomer")
    public ResultModel<List<CustomerResponse>> getCustomer(@RequestBody CustomerRequest request) {
        return customerService.getCustomer(request,true);
    }

    /**
     * 获取客户列表 PC端
     *
     * @param request
     * @return
     */
    @PostMapping("getCustomerPC")
    public ResultModel<Map<String, Object>> getCustomerPC(@RequestBody CustomerRequest request) {
        return customerService.getCustomerPC(request);
    }

    /**
     * 导出获取客户列表
     *
     * @return
     */
    @PostMapping("getCustomerExport")
    public ResultModel<ExportDataDTO<CustomerExcelEntity>> getCustomerExport(@RequestBody CustomerRequest request) {
        return customerService.getCustomerExport(request);
    }

    /**
     * 获取员工的客户
     *
     * @param request
     * @return
     */
    @PostMapping("selectCustomerList")
    public ResultModel selectCustomerList(@RequestBody CustomerRequest request) {
        return customerService.selectCustomerList(request);
    }

    /**
     * 获取客户信息
     *
     * @param cardId
     * @return
     */
    @PostMapping("getCustomerInfo")
    public ResultModel<GetCustomerInfoResponse> getCustomerInfo(@RequestParam("cardId") Long cardId) {
        return customerService.getCustomerInfo(cardId);
    }

    /**
     * 手动创建客户
     *
     * @return
     */
    @PostMapping("manualAdd")
    public ResultModel<Boolean> manualAdd(@RequestBody CustomerRequest request) {
        return customerService.manualAdd(request);
    }

    /**
     * 修改客户
     *
     * @return
     */
    @PostMapping("updCustomer")
    public ResultModel<Boolean> updCustomer(@RequestBody CustomerRequest request) {
        return customerService.updCustomer(request);
    }

    /**
     * 修改客户标签
     *
     * @param request
     * @return
     */
    @PostMapping("updCustomerLabel")
    public ResultModel<Boolean> updCustomerLabel(@RequestBody CustomerRequest request) {
        return customerService.updCustomerLabel(request);
    }

    /**
     * 修改客户类型
     *
     * @param request
     * @return
     */
    @PostMapping("updCustomerState")
    public ResultModel<Boolean> updCustomerState(@RequestBody CustomerRequest request) {
        return customerService.updCustomerState(request);
    }

    /**
     * 修改客户类型
     *
     * @param request
     * @return
     */
    @PostMapping("updBatchCustomerState")
    public ResultModel<Boolean> updBatchCustomerState(@RequestBody CustomerRequest request) {
        return customerService.updBatchCustomerState(request);
    }

    /**
     * 获取客户列表
     *
     * @param request
     * @return
     */
    @PostMapping("getCustomerList")
    public ResultModel<List<CustomerResponse>> getCustomerList(@RequestBody CustomerRequest request) {
        return customerService.getCustomerList(request);
    }
}
